################################## test_zero_mq ##################################
add_custom_command(
    OUTPUT
        ${CMAKE_CURRENT_SOURCE_DIR}/test_zero_mq/test_zero_mq.pb.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/test_zero_mq/test_zero_mq.pb.h
    MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/test_zero_mq/test_zero_mq.proto
    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
    COMMAND
        ./protobuf/bin/protoc --cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/test_zero_mq/
            -I ${CMAKE_CURRENT_SOURCE_DIR}/test_zero_mq/ test_zero_mq.proto
    COMMENT "Generate ${CMAKE_CURRENT_SOURCE_DIR}/test_zero_mq/test_zero_mq.pb.cc !"
)

add_executable(
    test_zero_mq_server
    test_zero_mq/server.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/test_zero_mq/test_zero_mq.pb.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/test_zero_mq/test_zero_mq.pb.h
)

target_link_libraries(
    test_zero_mq_server
    protobuf::libprotobuf
    ${ZeroMQ_STATIC_LIBRARY}
)

add_executable(
    test_zero_mq_client
    test_zero_mq/client.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/test_zero_mq/test_zero_mq.pb.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/test_zero_mq/test_zero_mq.pb.h
)

target_link_libraries(
    test_zero_mq_client
    protobuf::libprotobuf
    ${ZeroMQ_STATIC_LIBRARY}
)

################################## test_nanomsg ##################################
add_custom_command(
    OUTPUT
        ${CMAKE_CURRENT_SOURCE_DIR}/test_nanomsg/messages.pb.cc
        ${CMAKE_CURRENT_SOURCE_DIR}/test_nanomsg/messages.pb.h
    MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/test_nanomsg/messages.proto
    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
    COMMAND
        ./protobuf/bin/protoc --cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/test_nanomsg/
            -I ${CMAKE_CURRENT_SOURCE_DIR}/test_nanomsg/ messages.proto
    COMMENT "Generate ${CMAKE_CURRENT_SOURCE_DIR}/test_nanomsg/messages.pb.cc !"
)

add_executable(
    test_nanomsg_server
    test_nanomsg/server.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/test_nanomsg/messages.pb.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/test_nanomsg/messages.pb.h
)

target_link_libraries(
    test_nanomsg_server
    protobuf::libprotobuf
    nanomsg
)

add_executable(
    test_nanomsg_client
    test_nanomsg/client.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/test_nanomsg/messages.pb.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/test_nanomsg/messages.pb.h
)

target_link_libraries(
    test_nanomsg_client
    protobuf::libprotobuf
    nanomsg
)